package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.Result;
import com.itheima.service.CheckcordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import redis.clients.jedis.JedisPool;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/checkrecord")
public class CheckrecordController {
    @Autowired
    private JedisPool jedisPool;

    @Reference
    private CheckcordService checkcordService;

    @RequestMapping("/findCheckrecordByTelephone")
    public Result findCheckrecordByTelephone(String telephone){
        try {
            String memberStr = jedisPool.getResource().get(telephone);
            if (memberStr == null || memberStr.length() <= 0){
                return new Result(false,"您还没有登录,请先登录");
            }
            return checkcordService.findCheckrecordByTelephone(telephone);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"查询报告失败");
        }
    }
    @RequestMapping("/findByTelephone")
    public Result findByTelephone(String telephone){
        try {
            return checkcordService.findCheckrecordByTelephone(telephone);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"查询报告失败");
        }
    }
}
